<?php
/* 
* [***********************]
* @author: mazhenyu[houdunwangmzy@163.com]
* @Date:   2014-06-23 14:47:01
* @Last Modified time: 2014-06-23 15:51:23
*/
class WebSetModel extends Model{
	public $table = 'config';


	/**
	 * [get_all 获得所有配置项，按照类型重组]
	 * @return [type] [description]
	 */
	public function get_all(){
		$data = $this->all();
		$temp = array();
		foreach ($data as $v) {
			$temp[$v['type_id']][] = $v;
		}
		return $temp;
	}

	/**
	 * [update_data 修改配置项]
	 * @return [type] [description]
	 */
	public function update_data(){
		//修改配置项
		foreach ($_POST as $k => $v) {
			$this->where(array('name'=>$k))->save(array('value'=>$v));
		}
		$config = var_export($_POST,TRUE);
		$str = <<<str
<?php
if (!defined("HDPHP_PATH"))exit('No direct script access allowed');
return $config;
str;
		file_put_contents(COMMON_CONFIG_PATH . 'webConfig.php', $str);
	}
}
?>
